<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

class InforDetail
{
    public $login = true; //是否需要登录才能访问该接口
    public $title = "帖子详情ok";
    public $group = '帖子';
    public $desc = "";

    public $input = [
        'id' => 'int;label=id;',
    ];

    public $output = [
        'id' => 'label=id;',
        'img' => 'label=图片组;',
        'title' => 'label=标题;',
        'type' => 'label=信息类型;',
        'type_label' => 'label=信息类型标识;',
        'describe' => 'label=描述;',
        'mobile' => 'label=联系方式;',
        'contact' => 'label=联系人;',
        'create_time' => 'label=创建时间;',
        'state' => 'label=状态： 1上架 0下架;',
        'is_collect' => 'label=收藏状态： 0未收藏 1已收藏;',
    ];

    public function run($param, $uid)
    {

        $list = M('user_infor')
            ->where([
                'id' => $param['id'],
            ])
            ->find();
        $collect =  M('user_collect')->where(['relate_id' => $param['id'], 'type' => 1])
            ->find();
        $type = M('user_infor_type')->where(['id' => $list['type']])->find();
        $list['type_label'] = $type['name'];
        if($collect){
            $list['is_collect'] = 1;
        }else{
            $list['is_collect'] = 0;
        }

        return $list;
    }
}
